fix(delete): fix move to trash when parent folder is read-only
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Thu, 15 May 2025 10:30:25 +0000 (12:30 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Fri, 30 May 2025 07:07:46 +0000 (07:07 +0000)
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/propagatorjobs.cpp

index c2b929d83f1ed58508919f4a50bd31589022ffe4..272fe40b6280623b45bfa95745392b16fcfe1b14 100644 (file)
@@ -110,6 +110,9 @@ void PropagateLocalRemove::start()
     if (_moveToTrash && propagator()->syncOptions()._vfs->mode() != OCC::Vfs::WindowsCfApi) {
         const auto fileInfo = QFileInfo{filename};
         if (FileSystem::fileExists(filename, fileInfo)) {
+            const auto parentFolderPath = fileInfo.dir().absolutePath();
+            const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
+
             if (!FileSystem::moveToTrash(filename, &removeError)) {
                 qCWarning(lcPropagateLocalRemove()) << "move to trash failed" << filename << removeError;
                 done(SyncFileItem::NormalError, tr("Temporary error when removing local item removed from server."), ErrorCategory::GenericError);